const mysql = require('mysql')
//链接数据库
const con = mysql.createConnection({
    host: 'localhost',
    port: "3306",
    user: 'root',
    password: "521369",
    database: 'data1'
})
//开启链接
con.connect()
function query(sql) {
    return new Promise((resolve, reject) => {
        con.query(sql, (err, data) => {
            if (err) {
                reject(err)
            } else {
                resolve(data)
            }
        })
    })
}
module.exports = query